<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">
    <h:head>
        <title>Cadastro de Cliente</title>
        <link rel="stylesheet" type="text/css" href="../resources/css/cliente.css"/>
    </h:head>
    <h:body>
        <h:form>
            <h:messages></h:messages>
            <h:inputHidden value="#{clienteBean.cliente.numCliente}"></h:inputHidden>
            <h:inputHidden value="#{clienteBean.endereco.idEndereco}"></h:inputHidden>
            <h:panelGrid columns="2">
                <h:outputText id="lblNome" value="Nome:"></h:outputText>
                <h:inputText maxlength="100" value="#{clienteBean.cliente.nome}" required="true" requiredMessage="Informe o nome" styleClass="txtNomeCliente">
                    <f:validateLength minimum="10" maximum="30"></f:validateLength>
                </h:inputText>
                <h:outputText id="lblTelefone" value="Telefone:"></h:outputText>
                <h:inputText id="txtTelefone" maxlength="20" value="#{clienteBean.cliente.telefone}" required="true" requiredMessage="Informe o telefone" styleClass="txtTelefoneCliente"></h:inputText>
                <h:outputText id="lblEmail" value="E-mail:"></h:outputText>
                <h:inputText id="txtEmail" value="#{clienteBean.cliente.email}" maxlength="200" required="true" requiredMessage="Informe o email" styleClass="txtEmailCliente"></h:inputText>
                <h:outputText id="lblLogin" value="Login:"></h:outputText>
                <h:inputText id="txtLogin" value="#{clienteBean.cliente.login}" required="true" requiredMessage="Informe o login" styleClass="txtLoginCliente"></h:inputText>
                <h:outputText id="lblSenha" value="Senha:"></h:outputText>
                <h:inputSecret id="txtSenha" value="#{clienteBean.cliente.senha}" required="true" requiredMessage="Informe a senha" styleClass="txtSenhaCliente"></h:inputSecret>
                <h:outputText id="lblConfirmarSenha" value="Confirmar Senha:"></h:outputText>
                <h:inputSecret id="txtConfirmarSenha" value="#{clienteBean.cliente.senha}" required="true" requiredMessage="Informe o confirmar Senha" styleClass="txtConfirmarSenhaCliente"></h:inputSecret>
                <h:outputText id="lblRua" value="Rua:"></h:outputText>
                <h:inputText id="txtRua" maxlength="100" value="#{clienteBean.endereco.rua}" required="true" requiredMessage="Informe a rua" styleClass="txtRuaCliente"></h:inputText>
                <h:outputText id="lblNumero" value="Número:"></h:outputText>
                <h:inputText id="txtNumero" maxlength="20" value="#{clienteBean.endereco.numero}" required="true" requiredMessage="informe o número" styleClass="txtNumeroCliente"></h:inputText>
                <h:outputText id="lblCEP" value="CEP:"></h:outputText>
                <h:inputText id="txtCEP" value="#{clienteBean.endereco.cep}" maxlength="20" required="true" requiredMessage="Informe o CEP" styleClass="txtCEPCliente"></h:inputText>
                <h:outputText id="lblComplemento" value="Complemento:"></h:outputText>
                <h:inputText id="txtComplemento" value="#{clienteBean.endereco.logradouro}" maxlength="100" styleClass="txtComplementoCliente"></h:inputText>
                <h:outputText id="lblPontoReferencia" value="Referência:"></h:outputText>
                <h:inputText id="txtPontoReferencia" value="#{clienteBean.endereco.pontoReferencia}" maxlength="100" styleClass="txtreferenciaCliente"></h:inputText>
                <h:outputLabel id="lblPais" value="País:" for="lblPais"></h:outputLabel>
                <h:selectOneMenu id="slPais" styleClass="slPaisCliente" value="#{clienteBean.endereco.pais.idPais}"   valueChangeListener="#{clienteBean.mudarUF}"  required="true"
                    requiredMessage="Valor é obrigatório">
                    <f:selectItem itemValue="" itemLabel="Selecione uma País"/>
                    <f:selectItems  value="#{clienteBean.paises}" var="p" itemLabel="#{p.nome}" itemValue="#{p.idPais}"/>
                    <f:ajax event="change" render="cidades" />
                </h:selectOneMenu>
                <h:outputLabel id="lblUF" value="UF:" for="lblUF"></h:outputLabel>
                <h:selectOneMenu id="cidades" styleClass="slEstadoCliente" value="#{clienteBean.endereco.uf.idUF}"  required="true"
                    requiredMessage="Valor é obrigatório">
                    <f:selectItem itemValue="" itemLabel="Selecione uma UF"/>
                    <f:selectItems value="#{clienteBean.ufs}" var="u" itemLabel="#{u.sigla}" itemValue="#{u.idUF}" />
                </h:selectOneMenu>
            </h:panelGrid>
            <h:panelGrid columns="3">
                <h:commandButton action="#{clienteBean.novo}" value="Novo" styleClass="btnNovo"></h:commandButton>
                <h:commandButton action="#{clienteBean.salvar}" value="Salvar" styleClass="btnSalvar"></h:commandButton>
                <h:commandButton action="#{clienteBean.excluir}" value="Excluir" styleClass="btnExcluir"></h:commandButton>
            </h:panelGrid>
        </h:form>
    </h:body>
</html>
